package org.fat.nred.actd.tenant.service.impl;

import org.fat.nred.actd.tenant.entity.User;
import org.fat.nred.actd.tenant.mapper.UserMapper;
import org.fat.nred.actd.tenant.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Welisit
 * @since 2020-06-24
 */
@Service
public class UserServiceImpl implements UserService {


    @Resource
    private UserMapper userMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateUserName(Integer userId, String username) {
        User user = new User()
                .setId(userId)
                .setUsername(username)
                .setUpdateTime(new Date());
        userMapper.updateByPrimaryKeySelective(user);
        int i = 10/0;
        return true;
    }

    @Override
    public User getUserById(Integer userId) {
        return userMapper.selectById(userId);
    }
}
